<template>
	<view>
		<view class="header">
			<view class="header-title">
				2020年公司差旅费用
			</view>
<!-- 			<view class="header-detail">
				占用￥{{data.money}},占比{{data.overBudget}}
			</view> -->
		</view>
		<view class="main">
			<view class="main-header">
				<text class="main-header-left">2020年12月</text><text class="main-header-right">预算金额<text class="right-money">￥{{data.money}}</text></text>
			</view>
			<view class="main-chart">
				<view class="main-chart-left">
					<view class="qiun-charts">
						<canvas canvas-id="canvasRing1" id="canvasRing1" class="charts" :style="{'width':cWidth*pixelRatio+'px','height':cHeight*pixelRatio+'px', 'transform': 'scale('+(1/pixelRatio)+')','margin-left':-cWidth*(pixelRatio-1)/2+'px','margin-top':-cHeight*(pixelRatio-1)/2+'px'}"></canvas>
					</view>
				</view>
				<view class="main-chart-center">
					<view class="item-line">
						<text class="center-item-used">已用</text>
						<text class="">￥{{data.money}}</text>
					</view>
					<view class="item-linecenter-item-noUsed">
						<text class="center-item-noUsed">未用</text>
						<text class="">￥{{data.moneyNoUsed}}</text>
					</view>
				</view>
<!-- 				<view class="main-chart-right">
					<view class="item-line">
						
					</view>
					<view class="item-line center-item-noUsed">
						
					</view>
				</view> -->
			</view>
		</view>
		<view class="footer">
			<view class="footer-header ">
				子预算
			</view>
			<view class="footer-body header">
				<view class="footer-item" >
					<text>机票费</text><text style="float: right;">已用 ：￥4942.13</text>
				</view>
				<view class="footer-item" >
					<text>住宿费</text><text style="float: right;">已用 ：￥2645.13</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uCharts from '@/components/u-charts/u-charts.js';
	let canvasRing1 = null;
	let _self = this
	export default {
		onShow() {
			this.show()
		},
		data() {
			return {
				cWidth: '',
				cHeight: '',
				pixelRatio: 1,
				textarea: '',
				data: {
					money: '8511.18.00',
					moneyNoUsed:'3788.82',
					overBudget: '200%'
				},
				ringData: {
					"series": [{
						"data": 8511.18,
						"name": '金额',
						"color": '#FFC000'
					},{
						"data": 3788.82,
						"name": '金额',
						"color": '#7F7F7F'
					}]
				},
			}
		},
		methods: {
			show() {
				_self = this;
				this.cWidth = uni.upx2px(300);
				this.cHeight = uni.upx2px(300);
				this.showRing("canvasRing1", this.ringData, canvasRing1)
			},
			showRing(canvasId, chartData, canvaRing) {
				canvaRing = new uCharts({
					$this: _self,
					canvasId: canvasId,
					type: 'ring',
					fontSize: 11,
					padding: [5, 5, 5, 5],
					legend: {
						show: false
					},
					background: '#FFFFFF',
					pixelRatio: _self.pixelRatio,
					series: chartData.series,
					animation: false,
					width: _self.cWidth * _self.pixelRatio,
					height: _self.cHeight * _self.pixelRatio,
					disablePieStroke: true,
					dataLabel: false,
					title: {
						name: `69.20%`,
						color: '#7F7F7F',
						fontSize: 20,
					},
					subtitle: {
						name: '正常',
						fontSize: 15,
						color: '#7F7F7F',
					},
					extra: {
						pie: {
							ringWidth: 6 * _self.pixelRatio,
							offsetAngle:-90
						}
					},
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.header,
	.main,
	.footer {
		background-color: white;
	}
	.qiun-charts {
		width: 300upx;
		height: 300upx;
		background-color: #FFFFFF;
		margin: 0 auto;

		.charts {
			width: 300upx;
			height: 300upx;
			background-color: #FFFFFF;
		}
	}
	.header {
		padding: 30rpx;
		border-bottom: 1rpx solid $underline;
		.header-detail {
			background-color: #FFB682;
			border-radius: 50rpx;
			padding: 5rpx 10rpx;
			display: inline-block;
			font-size: 15rpx;
			color: white;
		}
	}

	.main {
		padding: 30rpx;
		.main-header {
			border-bottom: 1px solid $underline;
			height: 60rpx;
			line-height: 60rpx;
			.main-header-left{
				color: $uni-text-color-grey;
			}
			.main-header-right {
				float: right;
				.right-money {
					color: #FFB683;
				}
			}
		}

		.main-chart {
			display: flex;
			.main-chart-center {
				flex: 1;
				padding-top: 80rpx;
					.center-item-used{
						background-color: #FFC000;
						border-radius: 5rpx;
						padding: 5rpx;
						color: white;
					}
					.center-item-noUsed{
						background-color: $uni-text-color-grey;
						border-radius: 5rpx;
						padding: 5rpx;
						color: white;
					}
			}
			.main-chart-right{
				text-align: right;
				flex: 1;
				padding-top: 80rpx;
			}
		}
	}
	.item-line{
		height: 80rpx;
		
	}

	.footer{
		margin-top: 40rpx;
		background-color: white;
		.footer-item{
			height: 50rpx;
			line-height: 50rpx;
			color:#FFB683
		}
	}
</style>
